package com.sskj.gcc.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.gcc.ui.fragment.PayIn1Fragment;
import com.sskj.gocoin.MyAppLication;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.AseetListBean;
import com.sskj.gocoin.m.bean.RechargeInfoBean;
import com.sskj.gocoin.utils.ToastUtil;
import com.sskj.lib.http.JsonCallBack;

public class PayIn1FragmentPresenter extends BasePresenter<PayIn1Fragment> {
    public void recharge(int assetId) {
        OkGo.<HttpData<RechargeInfoBean>>post(HttpConfig.BASE_URL + HttpConfig.RECHARGE_URL)
//                .params("mobile", MyAppLication.getMobile())
                .params("type", assetId)
                .execute(new JsonCallBack<HttpData<RechargeInfoBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<RechargeInfoBean>> response) {
                        HttpData<RechargeInfoBean> httpListData = response.body();
                        if (httpListData.getCode() == 200) {
                            mView.updateView(httpListData.getData());
                        } else {
                            ToastUtil.showShort(httpListData.getMsg());
                        }
                    }
                });
    }



    public void requestUserAssetList() {
        OkGo.<HttpData<AseetListBean>>get(HttpConfig.BASE_URL+HttpConfig.ASEET_LIST)
                .params("mobile", MyAppLication.getMobile())
                .execute(new JsonCallBack<HttpData<AseetListBean>>(this,true) {
                    @Override
                    public void onSuccess(Response<HttpData<AseetListBean>> response) {
                        HttpData<AseetListBean> httpListData = response.body();
                        if (httpListData.getCode() == 200) {
                            mView.onDataSuccess(httpListData.getData());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<AseetListBean>> response) {
                        super.onError(response);
                    }
                });
    }
}
